package com.kotlin.demo.泛型

import com.kotlin.demo.类.Student

class DemoT2<T>(private val isR: Boolean, val obj: T) {

    fun show(): T? = obj.takeIf { isR }
}

class KtBase105<T> (val isMap : Boolean = false,val inputType : T){

    fun <R> map(mapAction:(T) ->R) = mapAction(inputType).takeIf{isMap}
}


fun main() {
    println(DemoT2(true, Student("za")).show())
    println(DemoT2(false, Student("ac")).show() ?: "返回的是null")

    println(DemoT2(true, Student("slkdjflsfj")).show()?.run {
        "返回值类型测试1"
    } ?: "返回值类型测试2")

    println(DemoT2(false, Student("zq")).show().apply {
        if (this == null) {
            "this == null "
        } else {
            "this != null "
        }
    })

    val map = KtBase105(true, 123).map {
        it
        "456"
    }
    println("map:${map.toString()}")




}

